#include "stdafx.h"
#include "SDLGmud.h"

bool SDLGmud::OnInit() 
{    
	//We are telling SDL to Initialize everything it has
	//This is the first thing we should do: start SDL itself
	if(SDL_Init(SDL_INIT_EVERYTHING) < 0)
	{
		return false;
	}

	//The next thing is to set video mode, which creates our window and our surface
	//4 params: the width of the window, the height of the window, 
	//the bit resolution of the window (recommended to be 16 or 32), and then display flags
	//Another flag that may interest you now is SDL_FULLSCREEN
	if((Surf_Display = SDL_SetVideoMode(WWIDTH, WHEIGHT, 32, SDL_HWSURFACE | SDL_DOUBLEBUF)) == NULL)
	{
		return false;
	}

	////Now let's actually load an image
	//if((Surf_Test = SDLSurface::OnLoad("./Resource/yoshi.bmp")) == NULL)
	//{
	//	return false;
	//}

	//Anim_Yoshi.MaxFrames = 8;
	//Anim_Yoshi.Oscillate = true;

	//if(Entity_Ninja.OnLoad("./Resource/ninja.bmp", 105, 520, 8) == false)
	//{
	//	return false;
	//}

	//GEntity::EntityList.push_back(&Entity_Ninja);

	if(GArea::AreaControl.OnLoad("./Maps/test.area") == false)
	{
		return false;
	}

	SDL_EnableKeyRepeat(1, SDL_DEFAULT_REPEAT_INTERVAL / 3);

	if (Player.OnLoad("./Resource/ninja.bmp", 64, 75, 8) == false)
	{
		return false;
	}

	GEntity::EntityList.push_back(&Player);

	GCamera::CameraControl.TargetMode = TARGET_MODE_CENTER;

	return true;
}